package com.probiz.estore.common.model.content.base;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.catalog.ContentCategory;
import com.probiz.estore.common.model.content.Content;
import com.probiz.estore.common.model.content.ContentRelatedType;
import com.probiz.estore.core.model.BaseObject;

/**
 * RelatedContent Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class RelatedContentTbl extends BaseObject implements Serializable {

    protected Integer relatedContentId;
    protected ContentRelatedType contentRelatedType; 
	protected Content content;
	protected Content sourceContent;
	protected ContentCategory sourceCategory;
	protected Short sourceKind;
	protected Integer sortOrder;
	protected Integer version;
	


	/**
	 * Default Empty Constructor for class RelatedContent
	 */
	public RelatedContentTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class RelatedContent
	 */
	public RelatedContentTbl (
		 Integer in_relatedContentId
        ) {
		this.setRelatedContentId(in_relatedContentId);
    }


	/**
	 * 	 * @return Integer
     * @hibernate.id column="relatedContentId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getRelatedContentId() {
		return this.relatedContentId;
	}
	
	/**
	 * Set the relatedContentId
	 */	
	public void setRelatedContentId(Integer aValue) {
		this.relatedContentId = aValue;
	}	

	
	public ContentRelatedType getContentRelatedType() {
		return contentRelatedType;
	}

	public void setContentRelatedType(ContentRelatedType contentRelatedType) {
		this.contentRelatedType = contentRelatedType;
	}

	public Integer getContentRelatedTypeId() {
		return this.getContentRelatedType()==null?null:this.getContentRelatedType().getContentRelatedTypeId();
	}
	
	public void setContentRelatedTypeId(Integer aValue) {
	    if (aValue==null) {
	    	contentRelatedType = null;
	    } else {
	        contentRelatedType = new ContentRelatedType(aValue);
	        contentRelatedType.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	
	

	public Content getContent() {
		return content;
	}

	public void setContent(Content content) {
		this.content = content;
	}

	public Integer getContentId() {
		return this.getContent()==null?null:this.getContent().getContentId();
	}
	
	public void setContentId(Integer aValue) {
		if (aValue==null) {
	    	content = null;
	    } else {
	    	content = new Content(aValue);
	    	content.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	
	
	

	public Content getSourceContent() {
		return sourceContent;
	}

	public void setSourceContent(Content sourceContent) {
		this.sourceContent = sourceContent;
	}

	public Integer getSourceContentId() {
		return this.getSourceContent()==null?null:this.getSourceContent().getContentId();
	}
	
	public void setSourceContentId(Integer aValue) {
	    if (aValue==null) {
	    	sourceContent = null;
	    } else {
	    	sourceContent = new Content(aValue);
	    	sourceContent.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	
	public ContentCategory getSourceCategory() {
		return sourceCategory;
	}

	public void setSourceCategory(ContentCategory sourceCategory) {
		this.sourceCategory = sourceCategory;
	}

	public Integer getSourceCategoryId() {
		return this.getSourceCategory()==null?null:this.getSourceCategory().getCategoryId();
	}
	public void setSourceCategoryId(Integer aValue) {
	    if (aValue==null) {
	    	sourceCategory = null;
	    } else {
	    	sourceCategory = new ContentCategory(aValue);
	    	sourceCategory.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * source的类型 0 = 文章  1= 文章目录。通过指定kind，sql匹配对应使用sourceProductId或者sourceCategoryId	 * @return Short
	 * @hibernate.property column="sourceKind" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getSourceKind() {
		return this.sourceKind;
	}
	
	/**
	 * Set the sourceKind
	 */	
	public void setSourceKind(Short aValue) {
		this.sourceKind = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 * @spring.validator type="required"
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof RelatedContentTbl)) {
			return false;
		}
		RelatedContentTbl rhs = (RelatedContentTbl) object;
		return new EqualsBuilder()
				.append(this.relatedContentId, rhs.relatedContentId)
				.append(this.sourceKind, rhs.sourceKind)
				.append(this.sortOrder, rhs.sortOrder)
				.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.relatedContentId) 
				.append(this.sortOrder) 
				.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("relatedContentId", this.relatedContentId) 
				.append("sourceKind", this.sourceKind) 
				.append("sortOrder", this.sortOrder) 
				.append("version", this.version) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "relatedContentId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return relatedContentId;
	}

}